// base
import Taro, { Component } from '@tarojs/taro'
import { View, Image } from '@tarojs/components'
import { AtActivityIndicator } from 'taro-ui'
// less
import './index.less'
import scaleImageSrc from '../../../../util/pagemethods/scaleImageSrc'
import If from '../../../../components/page-components/if'
import tool from '../../../../util/tool'

class BtmFixedBoss extends Component {
  componentWillMount () {
    // onLoad
  }

  componentDidMount () {
    // onready
  }

  componentDidShow () {
    // onshow
  }

  componentDidHide () {
    // onhide
  }

  componentWillUnmount () {
    // onUnload
  }

  delay (time = 0) {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve()
      }, time)
    })
  }

  callphone = tool.throttle(() => {
    this.props.onTap()
  })

  render () {
    const { user_avator, user_name, postion, sex } = this.props.detail || {}
    const { btnLoading } = this.props
    return (
      <View className="BtmFixedBoss_id36599">
        <View className="leftwrap">
          <Image
            className="avator"
            src={scaleImageSrc(
              user_avator ||
                (sex == '2'
                  ? 'https://imagesize.hrwork.com/sp/files/e309bd83-7ea5-4b01-97e4-4e67e7c17561.png'
                  : 'https://imagesize.hrwork.com/sp/files/07871efa-4a77-48d3-9192-7ad0ea47ff3e.png')
            )}
          />
          <View className="txtwrap">
            <View className="name">{user_name}</View>
            <View className="postion">{postion}</View>
          </View>
        </View>
        <View className="rightwrap">
          <If visible={btnLoading}>
            <AtActivityIndicator mode="center" color="#c9c9c9" />
          </If>
          <If visible={!btnLoading}>
            <View className="rightwrap-content" onClick={this.callphone}>
              <Image
                className="chatimg"
                src="https://imagesize.hrwork.com/sp/files/dda0d75d-2bab-4bb8-9ebe-76cc5d0ca74b.png"
              />
              <View className="chattxt">立即沟通</View>
            </View>
          </If>
        </View>
      </View>
    )
  }
}

export default BtmFixedBoss
